#!/bin/bash

## This Script will configure you Hostname!
## a file called ".network_set" will be created when the script
## was executed successfully

. $1
[ ${#@} -eq 1 ] || echo 'usage: network_cfg.sh config_file_name (most likely config.cfg)'
[ ${#@} -eq 1 ] || exit 1

if test -f /.network_set

then
echo "Netzwerk is already configured, to do this again, delete /.network_set"
read -n 1
else
echo "Hostname / Hostsdatei anpassen:"
echo "
127.0.0.1       localhost.localdomain   localhost
$MYextIP   $Hostname.$Domain     $Hostname

# The following lines are desirable for IPv6 capable hosts
::1     localhost ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
ff02::3 ip6-allhosts
" > /etc/hosts

echo $Hostname.$Domain > /etc/hostname

hostname
hostname -f
touch /.network_set

echo "Reboote needed - save your other work, then press return"
echo "!! open make_perfect.sh again after reboot !!"
read -n 1
shutdown -r now
sleep 999999

fi